#ifndef _DICTIONARY_H_
#define _DICTIONARY_H_

#include "Mylogger.hh"
#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
using std::pair;
using std::map;
using std::set;
using std::vector;
using std::string;
using std::ifstream;
using std::ofstream;
using std::istringstream;
using std::ostringstream;
using std::cout;




class Dictionary
{
public:
    //接口函数，输入查询词，返回相关词集合
    vector<pair<string,int>> doQuery(const string & key);

    static Dictionary* getInstance();
    //static void destroy();
    void print_dict();

private:
    Dictionary();
    Dictionary(const Dictionary &) = delete;
    Dictionary &operator = (const Dictionary &) = delete;
    ~Dictionary() = default;

    class AutoRelease
    {
    public:
        AutoRelease(){}
        ~AutoRelease(){
            if(_pInstance){
                delete _pInstance;
                _pInstance = nullptr;
            }
        }
    };

private:
     vector<pair<string,int>> _dict;
     map<string,set<int>> _index;
     static Dictionary* _pInstance;//单例模式
     static AutoRelease _ar;
};




#endif